#include "pch.h"
#include <iostream>
#include<fstream>
#include<iomanip>
#include<string>
#include<Windows.h>

using namespace std;

class commodityNode
{
public:
	commodityNode() { next = NULL; }
	string No;
	string Name;
	int Number;
	double Price;
	string Self;
	string Kind;
	commodityNode* next;
};

class commodity
{
private:
	commodityNode* node;
	commodityNode* headnode;
	commodityNode* lastnode;
	int sum = 0;
public:
	commodity();
	void traversal();
	void add(string, int, double, string, int);
	void change(int, double, commodityNode*);
	void change(int, commodityNode*);
	commodityNode* search(string);
	void sort(int);
	void write();
};
commodity commod;
class userNode
{
public:
	userNode() { next = NULL; }
	string No;
	string Name;
	string Telephone;
	string Password;
	userNode* next;
};

class users
{
private:
	userNode* node;
	userNode* headnode;
	userNode* lastnode;
	userNode* nownode;
	userNode* lastnownode;
	int sum = 0;
	bool loginstatus = false;
public:
	users();
	bool login(string, string);//是否需要bool返回值存疑
	void logout();
	void logoff();
	void change(string, string, string, int);//根据图形化界面  应对应界面进行单独项的修改
	void Register(string, string, string);
	string getname();
	bool getstatus() { return loginstatus; }
	void write();
};
class orderNode
{
public:
	orderNode() { next = NULL;com = new commodityNode; }
	commodityNode* com;
	int number;
	double price;
	string No;
	orderNode* next;
};
class order
{
private:
	orderNode* node;
	orderNode* headnode;
	orderNode* lastnode;
	int sum = 0, tempnum;
	string tempno;
	double tempprice = 0;
	double sumprice = 0;
public:
	order();
	void display();
	bool deleteorder(string);
	bool search(string);
	void add(commodityNode*, int);
	void QRcode();
	double getprice() { return tempprice; }
	double getsumprice() { return sumprice; }
	void changesumprice(int a) { sumprice = a; }
	void deleteall();
	int gettempnum() { return tempnum; }
	string gettempno() { return tempno; }
	void back()
	{
		orderNode* temp = (headnode->next);
		orderNode* deltemp;
		commodityNode * tempnode;
		while (temp != NULL)
		{
			deltemp = temp;
			temp = temp->next;
			deleteorder(deltemp->No);
			tempnode = commod.search(gettempno());
			tempnum = (tempnode->Number) + gettempnum();
			commod.change(tempnum, tempnode);
		}
		lastnode = headnode;
	}
};
users::users()
{
	headnode = new userNode;
	lastnode = headnode;
	ifstream ifile;
	ifile.open("E:\\users.txt");
	if (!ifile)
	{
		ofstream file("E:\\users.txt", fstream::out);
		file.close();
		ifile.open("E:\\users.txt");
	}
	string no, name, tel, pw;
	while (1)
	{
		ifile >> no >> name >> tel >> pw;
		if (ifile.eof() != 0) break;
		node = new userNode;
		node->No = no;
		node->Name = name;
		node->Telephone = tel;
		node->Password = pw;
		sum = stoi(no);
		lastnode->next = node;
		lastnode = node;
	}
	ifile.close();
}

bool users::login(string tp, string pw)
{
	userNode* temp = (headnode->next);
	lastnownode = headnode;
	while (temp != NULL)
	{
		if ((temp->Password) == pw)
		{
			if (((temp->Name) == tp) || ((temp->Telephone) == tp))
			{
				nownode = temp;
				loginstatus = true;
				return true;
			}
		}
		lastnownode = temp;
		temp = temp->next;
	}
	return false;
}

void users::logout()
{
	loginstatus = false;
}

void users::Register(string name, string tel, string pw)
{
	userNode* temp = new userNode;
	sum++;
	string no = to_string(sum);
	while (no.size() < 4)
	{
		no = "0" + no;
	}
	temp->No = no;
	temp->Name = name;
	temp->Telephone = tel;
	temp->Password = pw;
	lastnode->next = temp;
	lastnode = temp;
}

void users::logoff()
{
	lastnownode->next = nownode->next;
	if ((lastnownode->next) == NULL)
		lastnode = lastnownode;
	loginstatus = false;
	delete nownode;
}

void users::change(string name, string tel, string pw, int pick)
{
	switch (pick)
	{
	case 1:
		nownode->Name = name;
		break;
	case 2:
		nownode->Telephone = tel;
		break;
	case 3:
		nownode->Password = pw;
		break;
	case 4:
		nownode->Name = name;
		nownode->Telephone = tel;
		break;
	case 5:
		nownode->Name = name;
		nownode->Password = pw;
		break;
	case 6:
		nownode->Telephone = tel;
		nownode->Password = pw;
		break;
	}
}

string users::getname()
{
	if (loginstatus == false)
		return "未登录";
	else
		return nownode->Name;
}
void users::write()
{
	ofstream ofile;
	ofile.open("E:\\users.txt");
	userNode* temp = (headnode->next);
	while (temp != NULL)
	{
		ofile << setw(20) << temp->No << setw(20) << temp->Name << setw(20) << temp->Telephone << setw(20) << temp->Password << endl;
		temp = temp->next;
	}
	ofile.close();
}
commodity::commodity()
{
	headnode = new commodityNode;
	lastnode = headnode;
	ifstream ifile;
	ifile.open("E:\\commodity.txt");
	if (!ifile)
	{
		ofstream file("E:\\commodity.txt", fstream::out);
		file.close();
		ifile.open("E:\\commodity.txt");
	}
	string no, name, self, kind;
	int number;
	double price;
	while (1)
	{
		ifile >> no >> name >> number >> price >> self >> kind;
		if (ifile.eof() != 0) break;
		node = new commodityNode;
		node->No = no;
		node->Name = name;
		node->Number = number;
		node->Price = price;
		node->Self = self;
		node->Kind = kind;
		sum = stoi(no);
		lastnode->next = node;
		lastnode = node;
	}
	ifile.close();
}
void commodity::traversal()
{
	commodityNode* temp = (headnode->next);
	while (temp != NULL)
	{
		cout << "编号:" << temp->No << "    种类:" << temp->Kind << "    名称:" << temp->Name << "    数量:" << temp->Number << "    价格:" << temp->Price;
		if ((temp->Kind) == "日用品")
			cout << "    净含量:" << temp->Self << endl;
		else if ((temp->Kind) == "食品")
			cout << "    保质期:" << temp->Self << endl;
		else if ((temp->Kind) == "家电")
			cout << "    颜色:" << temp->Self << endl;
		else
			cout << "    尺码:" << temp->Self << endl;
		temp = temp->next;
	}
}
void commodity::add(string name, int number, double price, string self, int pick)
{
	commodityNode* temp = new commodityNode;
	sum++;
	string no = to_string(sum);
	while (no.size() < 4)
	{
		no = "0" + no;
	}
	temp->No = no;
	temp->Name = name;
	temp->Number = number;
	temp->Price = price;
	temp->Self = self;
	switch (pick)
	{
	case 1:
		temp->Kind = "日用品";
		break;
	case 2:
		temp->Kind = "食品";
		break;
	case 3:
		temp->Kind = "家电";
		break;
	case 4:
		temp->Kind = "服装";
		break;
	}
	lastnode->next = temp;
	lastnode = temp;
}
commodityNode* commodity::search(string se)
{
	commodityNode* temp = (headnode->next);
	while (temp != NULL)
	{
		if (((temp->No) == se) || ((temp->Name) == se))
			return temp;
		temp = temp->next;
	}
	return NULL;
}
void commodity::change(int number, double price, commodityNode* tp)
{
	tp->Number = number;
	tp->Price = price;
}
void commodity::change(int number, commodityNode* tp)
{
	tp->Number = number;
}
void commodity::sort(int pick)
{
	commodityNode* temp = (headnode->next);
	string tempstring;
	switch (pick)
	{
	case 1:
		tempstring = "日用品";
		break;
	case 2:
		tempstring = "食品";
		break;
	case 3:
		tempstring = "家电";
		break;
	case 4:
		tempstring = "服装";
		break;
	}
	while (temp != NULL)
	{
		if ((temp->Kind) == tempstring)
		{
			cout << "编号:" << temp->No << "    种类:" << temp->Kind << "    名称 :" << temp->Name << "    数量:" << temp->Number << "    价格:" << temp->Price;
			if (tempstring == "日用品")
				cout << "    净含量:" << temp->Self << endl;
			else if (tempstring == "食品")
				cout << "    保质期:" << temp->Self << endl;
			else if (tempstring == "家电")
				cout << "    颜色:" << temp->Self << endl;
			else
				cout << "    尺码:" << temp->Self << endl;
		}
		temp = temp->next;
	}
}
void commodity::write()
{
	ofstream ofile;
	ofile.open("E:\\commodity.txt");
	commodityNode* temp = (headnode->next);
	while (temp != NULL)
	{
		ofile << setw(20) << temp->No << setw(20) << temp->Name << setw(20) << temp->Number << setw(20) << temp->Price << setw(20) << temp->Self << setw(20) << temp->Kind << endl;
		temp = temp->next;
	}
	ofile.close();
}
order::order()
{
	headnode = new orderNode;
	lastnode = headnode;
}

void order::display()
{
	orderNode* temp = (headnode->next);
	while (temp != NULL)
	{
		cout << "订单号:" << temp->No << "    商品名:" << temp->com->Name << "    数量:" << temp->number << "    总价:" << temp->price << endl;
		temp = temp->next;
	}
}
bool order::deleteorder(string no)
{
	orderNode* temp = (headnode->next);
	orderNode* lasttemp = headnode;
	while (temp != NULL)
	{
		if ((temp->No) == no)
		{
			tempprice = temp->price;
			tempnum = temp->number;
			tempno = (temp->com->No);
			lasttemp->next = temp->next;
			if ((lasttemp->next) == NULL)
				lastnode = lasttemp;
			delete temp;
			return true;
		}
		temp = temp->next;
		lasttemp = lasttemp->next;
	}
	return false;
}
bool order::search(string no)
{
	orderNode* temp = (headnode->next);
	while (temp != NULL)
	{
		if ((temp->No) == no)
		{
			cout << "类别:" << temp->com->Kind << "    名称:" << temp->com->Name << "    单价:" << temp->com->Price << "    购买数量:" << temp->number << "    总价:" << temp->price << endl;
			return true;
		}
		temp = temp->next;
	}
	return false;
}
void order::add(commodityNode* tp, int nu)
{
	orderNode* temp = new orderNode;
	sum++;
	string no = to_string(sum);
	while (no.size() < 4)
	{
		no = "0" + no;
	}
	temp->No = no;
	temp->com = tp;
	temp->number = nu;
	temp->price = (tp->Price)*nu;
	sumprice = sumprice + (temp->price);
	lastnode->next = temp;
	lastnode = temp;
}
void order::deleteall()
{
	orderNode* temp = (headnode->next);
	orderNode* deltemp;
	while (temp != NULL)
	{
		deltemp = temp;
		temp = temp->next;
		delete deltemp;
	}
	lastnode = headnode;
	headnode->next = NULL;
}
void order::QRcode()
{
	cout << "▇▇▇▇▇▇▇  ▇▇▇    ▇▇  ▇      ▇    ▇  ▇▇▇▇▇▇▇" << endl;
	cout << "▇          ▇  ▇    ▇      ▇▇      ▇  ▇    ▇          ▇" << endl;
	cout << "▇  ▇▇▇  ▇  ▇            ▇  ▇    ▇  ▇    ▇  ▇▇▇  ▇" << endl;
	cout << "▇  ▇▇▇  ▇  ▇▇  ▇  ▇  ▇  ▇  ▇  ▇      ▇  ▇▇▇  ▇" << endl;
	cout << "▇  ▇▇▇  ▇      ▇▇▇    ▇      ▇  ▇      ▇  ▇▇▇  ▇" << endl;
	cout << "▇          ▇  ▇    ▇        ▇▇    ▇  ▇    ▇          ▇" << endl;
	cout << "▇▇▇▇▇▇▇    ▇▇▇  ▇    ▇    ▇    ▇    ▇▇▇▇▇▇▇" << endl;
	cout << "        ▇▇    ▇  ▇  ▇▇    ▇▇    ▇▇  ▇  ▇    ▇  ▇  " << endl;
	cout << "  ▇      ▇              ▇    ▇▇    ▇▇  ▇  ▇    ▇  ▇  " << endl;
	cout << " ▇     ▇     ▇   ▇   ▇    ▇▇     ▇  ▇  ▇    ▇  ▇  ▇" << endl;
	cout << "   ▇     ▇    ▇      ▇    ▇  ▇      ▇  ▇  ▇  ▇  ▇  ▇" << endl;
	cout << "      ▇  ▇    ▇  ▇  ▇▇     ▇▇     ▇  ▇  ▇    ▇  ▇  " << endl;
	cout << "  ▇    ▇    ▇   ▇   ▇    ▇▇      ▇  ▇  ▇    ▇  ▇  ▇" << endl;
	cout << "     ▇   ▇    ▇  ▇  ▇▇    ▇▇    ▇▇  ▇  ▇    ▇  ▇  " << endl;
	cout << "  ▇    ▇  ▇      ▇      ▇  ▇     ▇  ▇  ▇  ▇     ▇  ▇" << endl;
	cout << "      ▇  ▇    ▇  ▇  ▇▇     ▇▇     ▇  ▇  ▇    ▇  ▇  " << endl;
	cout << "  ▇    ▇     ▇   ▇    ▇   ▇▇     ▇  ▇  ▇    ▇  ▇  ▇" << endl;
	cout << "  ▇      ▇      ▇       ▇    ▇▇     ▇  ▇  ▇    ▇  ▇  " << endl;
	cout << "        ▇▇    ▇  ▇  ▇▇   ▇▇    ▇▇  ▇  ▇     ▇  ▇  " << endl;
	cout << "      ▇  ▇    ▇  ▇    ▇     ▇▇     ▇  ▇  ▇    ▇  ▇  " << endl;
	cout << "▇▇▇▇▇▇▇  ▇▇▇    ▇▇  ▇      ▇    ▇  ▇  ▇  ▇▇  " << endl;
	cout << "▇          ▇  ▇    ▇      ▇▇      ▇  ▇    ▇    ▇    ▇" << endl;
	cout << "▇  ▇▇▇  ▇  ▇            ▇   ▇   ▇  ▇      ▇    ▇  ▇" << endl;
	cout << "▇  ▇▇▇  ▇  ▇▇    ▇  ▇  ▇  ▇  ▇      ▇  ▇  ▇  ▇▇" << endl;
	cout << "▇  ▇▇▇  ▇      ▇▇    ▇    ▇  ▇  ▇  ▇    ▇  ▇▇    " << endl;
	cout << "▇          ▇  ▇    ▇        ▇▇    ▇  ▇    ▇          ▇" << endl;
	cout << "▇▇▇▇▇▇▇    ▇▇▇  ▇    ▇    ▇  ▇        ▇▇    ▇▇" << endl;
}
int main()
{
	users user;
	order ord;
	string name, tel, pw, se, no;
	commodityNode* tempnode;
	char logofftemp, tempchar;
	int switchnumber, tempswitchnumber, pick = 0, number, tempnum;
	double price;
	bool flag = true, buyflag = true, orderflag, logstatus;
	while (1)
	{
		flag = true;
		cout << "--------------欢迎来到购物系统--------------" << endl;
		cout << "请输入相对应的数字来执行操作!" << endl;
		logstatus = user.getstatus();
		if (logstatus)
			cout << "                     当前用户:" << user.getname() << endl;
		else
			cout << "                          未登录" << endl;
		cout << "1.商品管理" << endl;
		cout << "2.用户信息管理" << endl;
		cout << "3.订单管理" << endl;
		cout << "4.支付" << endl;
		if (user.getstatus())
			cout << "5.登出" << endl;
		else
			cout << "5.登录" << endl;
		cout << "6.注册" << endl;
		cout << "7.退出系统" << endl;
		cin >> switchnumber;
		system("cls");
		switch (switchnumber)
		{
		case 1:
			while (flag == true)
			{
				cout << "--------------商品管理--------------" << endl;
				cout << "1.分类显示" << endl;
				cout << "2.显示商品" << endl;
				cout << "3.添加商品" << endl;
				cout << "4.修改商品数量和价格" << endl;
				cout << "5.将指定商品加入订单" << endl;
				cout << "6.返回" << endl;
				cin >> tempswitchnumber;
				system("cls");
				switch (tempswitchnumber)
				{
				case 1:
					cout << "请选择您想要显示的商品类!" << endl;
					cout << "1.日用品类" << endl;
					cout << "2.食品类" << endl;
					cout << "3.家电类" << endl;
					cout << "4.服装类" << endl;
					cin >> pick;
					while ((pick != 1) && (pick != 2) && (pick != 3) && (pick != 4))
					{
						cout << "输入有误,请重新输入!" << endl;
						cin >> pick;
					}
					cout << endl;
					commod.sort(pick);
					getchar();
					getchar();
					system("cls");
					break;
				case 2:
					commod.traversal();
					getchar();
					getchar();
					system("cls");
					break;
				case 3:
					cout << "请选择您想要添加的商品类!" << endl;
					cout << "1.日用品类" << endl;
					cout << "2.食品类" << endl;
					cout << "3.家电类" << endl;
					cout << "4.服装类" << endl;
					cin >> pick;
					while ((pick != 1) && (pick != 2) && (pick != 3) && (pick != 4))
					{
						cout << "输入有误,请重新输入!" << endl;
						cin >> pick;
					}
					cout << "请输入商品名!" << endl;
					cin >> name;
					cout << "请输入数量!" << endl;
					cin >> number;
					cout << "请输入单价!" << endl;
					cin >> price;
					switch (pick)
					{
					case 1:
						cout << "请输入净含量!" << endl;
						cin >> se;
						break;
					case 2:
						cout << "请输入保质期!" << endl;
						cin >> se;
						break;
					case 3:
						cout << "请输入颜色!" << endl;
						cin >> se;
						break;
					case 4:
						cout << "请输入尺码!" << endl;
						cin >> se;
						break;
					}
					commod.add(name, number, price, se, pick);
					cout << "添加成功!" << endl;
					getchar();
					getchar();
					system("cls");
					break;
				case 4:
					cout << "请输入您想要修改的商品名称或ID!" << endl;
					cin >> name;
					tempnode = commod.search(name);
					if (tempnode == NULL)
						cout << "没有此商品!" << endl;
					else
					{
						cout << "请输入修改后的商品数量!" << endl;
						cin >> number;
						cout << "请输入修改后的商品单价!" << endl;
						cin >> price;
						commod.change(number, price, tempnode);
						cout << "修改成功!" << endl;
					}
					getchar();
					getchar();
					system("cls");
					break;
				case 5:
					buyflag = true;
					cout << "--------------商品目录--------------" << endl;
					commod.traversal();
					while (buyflag == true)
					{
						cout << "请输入您想要加入订单的商品名称或ID!" << endl;
						cin >> name;
						tempnode = commod.search(name);
						if (tempnode == NULL)
							cout << "没有此商品!" << endl;
						else
						{
							cout << "请输入要加入的数量!" << endl;
							cin >> tempnum;
							if ((tempnode->Number) < tempnum)
							{
								cout << "库存不足,加入失败!" << endl;
							}
							else
							{
								(tempnode->Number) = (tempnode->Number) - tempnum;
								ord.add(tempnode, tempnum);
							}
						}
						cout << "如果想继续添加请输入Y,否则请按任意键." << endl;
						cin >> tempchar;
						if (tempchar != 'Y')
						{
							buyflag = false;
						}
					}
					getchar();
					system("cls");
					break;
				case 6:
					flag = false;
					break;
				default:
					cout << "输入有误,请重新输入!" << endl;
					getchar();
					getchar();
					system("cls");
					break;
				}
			}
			break;
		case 2:
			if (logstatus == false)
			{
				cout << "请先登录!" << endl;
				getchar();
				getchar();
				system("cls");
			}
			else
			{
				while (flag == true)
				{
					cout << "--------------用户信息管理--------------" << endl;
					cout << "1.基本信息维护" << endl;
					cout << "2.注销" << endl;
					cout << "3.返回" << endl;
					cin >> tempswitchnumber;
					system("cls");
					switch (tempswitchnumber)
					{
					case 1:
						cout << "请选择您想要更改的数据!" << endl;
						cout << "1.用户名" << endl;
						cout << "2.电话" << endl;
						cout << "3.密码" << endl;
						cout << "4.用户名和电话" << endl;
						cout << "5.用户名和密码" << endl;
						cout << "6.电话和密码" << endl;
						cin >> pick;
						switch (pick)
						{
						case 1:
							cout << "请输入新用户名!" << endl;
							cin >> name;
							user.change(name, tel, pw, pick);
							cout << "修改成功!" << endl;
							getchar();
							getchar();
							system("cls");
							break;
						case 2:
							cout << "请输入新电话!" << endl;
							cin >> tel;
							user.change(name, tel, pw, pick);
							cout << "修改成功!" << endl;
							getchar();
							getchar();
							system("cls");
							break;
						case 3:
							cout << "请输入新密码!" << endl;
							cin >> pw;
							user.change(name, tel, pw, pick);
							cout << "修改成功!" << endl;
							getchar();
							getchar();
							system("cls");
							break;
						case 4:
							cout << "请输入新用户名!" << endl;
							cin >> name;
							cout << "请输入新电话!" << endl;
							cin >> tel;
							user.change(name, tel, pw, pick);
							cout << "修改成功!" << endl;
							getchar();
							getchar();
							system("cls");
							break;
						case 5:
							cout << "请输入新用户名!" << endl;
							cin >> name;
							cout << "请输入新密码!" << endl;
							cin >> pw;
							user.change(name, tel, pw, pick);
							cout << "修改成功!" << endl;
							getchar();
							getchar();
							system("cls");
							break;
						case 6:
							cout << "请输入新电话!" << endl;
							cin >> tel;
							cout << "请输入新密码!" << endl;
							cin >> pw;
							user.change(name, tel, pw, pick);
							cout << "修改成功!" << endl;
							getchar();
							getchar();
							system("cls");
							break;
						default:
							cout << "输入错误,程序即将返回!" << endl;
							getchar();
							Sleep(2000);
							system("cls");
							break;
						}
						break;
					case 2:
						cout << "您确定要进行此操作吗? 这将会从系统中删除您的账户!" << endl;
						cout << "输入Y继续,输入其他键退出." << endl;
						cin >> logofftemp;
						if (logofftemp == 'Y')
						{
							user.logoff();
							flag = false;
							cout << "注销成功!" << endl;
						}
						getchar();
						getchar();
						system("cls");
						break;
					case 3:
						flag = false;
						break;
					default:
						cout << "输入有误,请重新输入!" << endl;
						getchar();
						getchar();
						system("cls");
						break;
					}
				}
			}
			break;
		case 3:
			while (flag == true)
			{
				cout << "--------------订单管理--------------" << endl;
				cout << "1.显示订单" << endl;
				cout << "2.删除订单" << endl;
				cout << "3.查询订单" << endl;
				cout << "4.返回" << endl;
				cin >> tempswitchnumber;
				switch (tempswitchnumber)
				{
				case 1:
					ord.display();
					getchar();
					getchar();
					system("cls");
					break;
				case 2:
					cout << "请输入要删除订单的订单号!" << endl;
					cin >> no;
					orderflag = ord.deleteorder(no);
					if (orderflag == true)
					{
						ord.changesumprice(ord.getsumprice() - ord.getprice());
						tempnode = commod.search(ord.gettempno());
						tempnum = (tempnode->Number) + ord.gettempnum();
						commod.change(tempnum, tempnode);
						cout << "删除成功!" << endl;
					}
					else
						cout << "无此订单!" << endl;
					getchar();
					getchar();
					system("cls");
					break;
				case 3:
					cout << "请输入要查询订单的订单号!" << endl;
					cin >> no;
					orderflag = ord.search(no);
					if (orderflag == false)
						cout << "无此订单!" << endl;
					getchar();
					getchar();
					system("cls");
					break;
				case 4:
					flag = false;
					getchar();
					system("cls");
					break;
				default:
					cout << "输入有误,请重新输入!" << endl;
					break;
				}
			}
			break;
		case 4:
			while (flag == true)
			{
				cout << "--------------支付--------------" << endl;
				cout << "1.指定支付" << endl;
				cout << "2.全部支付" << endl;
				cout << "3.返回" << endl;
				cin >> tempswitchnumber;
				switch (tempswitchnumber)
				{
				case 1:
					cout << "请输入要支付订单的订单号!" << endl;
					cin >> no;
					ord.search(no);
					orderflag = ord.deleteorder(no);
					if (orderflag == true)
					{
						cout << "输入A使用支付宝付款,输入其他键使用微信支付." << endl;
						cin >> tempchar;
						if (tempchar == 'A')
						{
							cout << "您已选择支付宝付款" << endl;
						}
						else
						{
							cout << "您已选择微信支付" << endl;
						}
						cout << "所需支付费用为:" << ord.getprice() << endl;
						ord.changesumprice((ord.getsumprice() - ord.getprice()));
						ord.QRcode();
					}
					else
						cout << "无此订单!" << endl;
					getchar();
					getchar();
					system("cls");
					break;
				case 2:
					ord.display();
					cout << "输入A使用支付宝付款,输入其他键使用微信支付." << endl;
					cin >> tempchar;
					if (tempchar == 'A')
					{
						cout << "您已选择支付宝付款" << endl;
					}
					else
					{
						cout << "您已选择微信支付" << endl;
					}
					cout << "所需支付费用为:" << ord.getsumprice() << endl;
					ord.changesumprice(0);
					ord.deleteall();
					ord.QRcode();
					getchar();
					getchar();
					system("cls");
					break;
				case 3:
					getchar();
					system("cls");
					flag = false;
					break;
				default:
					cout << "输入有误,请重新输入!" << endl;
					getchar();
					getchar();
					system("cls");
					break;
				}
			}
			break;
		case 5:
			if (user.getstatus())
			{
				user.logout();
				cout << "登出成功!" << endl;
				getchar();
				getchar();
				system("cls");
			}
			else
			{
				string tp;
				string pass;
				bool tempor;
				cout << "请输入ID或用户名!" << endl;
				cin >> tp;
				cout << "请输入密码!" << endl;
				cin >> pass;
				tempor = (user.login(tp, pass));
				if (tempor == true)
					cout << "登录成功!" << endl;
				else
					cout << "用户不存在!" << endl;
				getchar();
				getchar();
				system("cls");
			}
			break;
		case 6:
			cout << "请输入要注册用户的用户名!" << endl;
			cin >> name;
			cout << "请输入要注册用户的电话号码!" << endl;
			cin >> tel;
			cout << "请输入要注册用户的密码!" << endl;
			cin >> pw;
			user.Register(name, tel, pw);
			cout << "注册成功!" << endl;
			getchar();
			getchar();
			system("cls");
			break;
		case 7:
			goto end;
			break;
		default:
			cout << "输入有误,请重新输入!" << endl;
			getchar();
			getchar();
			system("cls");
			break;
		}
	}
end:
	ord.back();
	user.write();
	commod.write();
	return 0;
}